# Python 2.6.4
# Project Euler, Problem 188
# Copyright 2010 Talha Zaman

def tetra(a, b):
    x = a
    for i in xrange(1, b):
        x = pow(a, x, int(1e8))
    return x

print tetra(1777, 1855)
